package hxz.controller;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

/**
 * 用户信息注册控制器
 * 
 * @author hxz
 * @date 2017/07/09
 * @version 1.0
 */
public class UserInfoController implements Controller {

	@Override
	public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
		request.setCharacterEncoding("GBK"); 
		// 用户信息
		String userInfo = "用户账号："+request.getParameter("userId")+" "
			+"真实姓名："+request.getParameter("userName")+" "
			+"姓名拼音："+request.getParameter("userPhonetic")+" "
			+"性别："+request.getParameter("sex")+" "
			+"民族："+request.getParameter("nation")+" "
			+"联系手机："+request.getParameter("cellphone")+" "
			+"Email："+request.getParameter("email")+" "
			+"所在单位："+request.getParameter("workLocation")+" "
			+"密码："+request.getParameter("password");
		File writename = new File("F:\\userInfo.txt"); 
		writename.createNewFile(); 
		BufferedWriter bw = new BufferedWriter(new FileWriter(writename));  
		bw.write(userInfo);
		bw.flush();
		bw.close();
		// 返回ModelAndView
		ModelAndView mv = new ModelAndView();
		// 指定视图
		mv.setViewName("success");
		return mv;
	}

}
